package redisinit

import (
	"context"
	"github.com/go-redis/redis/v8"
	"github.com/zeromicro/go-zero/core/logx"
	"house_srv/appconfig"
)

var Ctx = context.Background()
var (
	Rdb *redis.Client
	err error
)

func RedisClient() {
	Rdb = redis.NewClient(&redis.Options{
		Addr:     appconfig.AppConf.RedisConfig.Addr,
		Password: appconfig.AppConf.RedisConfig.Password, // no password set
		DB:       appconfig.AppConf.RedisConfig.Db,       // use default DB
	})

	err = Rdb.Set(Ctx, "key", "value", 0).Err()
	if err != nil {
		panic(err)
	}
	logx.Error("redis连接成功")
}
